package com.swinboo.im.converter;

import com.alibaba.fastjson.JSON;
import com.huang.base.core.BaseConvertor;
import com.swinboo.im.entity.param.SendSingleMsgParam;
import com.swinboo.im.entity.to.EMMsgBody;
import org.springframework.stereotype.Component;

/**
 * @author Swinboo
 * @date 2022-03-19 22:36
 * @description:
 */
@Component
public class SendSingleMsgParam2EMMsgBody extends BaseConvertor<SendSingleMsgParam, EMMsgBody> {

    @Override
    public EMMsgBody doConvert(SendSingleMsgParam param) {
        EMMsgBody emMsgBody = new EMMsgBody();
        emMsgBody.setFrom(param.getFromUId());
        emMsgBody.setTo(param.getToUId());
        emMsgBody.setMsgBody(JSON.toJSONString(param));
        emMsgBody.setMsgType(param.getType());
        return emMsgBody;
    }
}
